package TCP.UDP;

import java.net.DatagramPacket;
import java.net.DatagramSocket;
import java.net.InetAddress;

public class Client {
    public static void main(String[] args) throws Exception {
        //封装一个数据包
        String msg = "今天天气不错！";
        byte[] b = msg.getBytes();
        InetAddress address = InetAddress.getByName("localhost");//本机地址
        DatagramPacket dp = new DatagramPacket(b,0,b.length,address,8888);
        //发送
        DatagramSocket ds = new DatagramSocket();
        ds.send(dp);
    }
}
